/*
This file is part of La Linea.

La Linea is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

La Linea is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with La Linea.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui>

#include "Animation.h"
#include "DisplayWidget.h"
#include "Frame.h"
#include "PropertyItemModel.h"

class MainWindow : public QMainWindow {
	Q_OBJECT

	private:
		// MENUS
		QMenu *fileMenu;
		QMenu *editMenu;
		QMenu *editModeMenu;
		QMenu *displayMenu;
		QMenu *insertFrameMenu;
		QMenu *duplicateFrameMenu;
		QMenu *stencilMenu;
		
		// ACTIONS
		QAction *newAction;
		QAction *openAction;
		QAction *saveAsAction;
		QAction *saveAction;		
		QAction *quitAction;
		QAction *insertFrameBeginAction;
		QAction *insertFrameEndAction;
		QAction *insertFrameBeforeAction;
		QAction *insertFrameAfterAction;
		QAction *duplicateFrameBeginAction;
		QAction *duplicateFrameEndAction;
		QAction *duplicateFrameBeforeAction;
		QAction *duplicateFrameAfterAction;
		QAction *clearFrameAction;
		QAction *removeFrameAction;
		QAction *nextFrameAction;
		QAction *previousFrameAction;
		QAction *increaseFrameAction;
		QAction *decreaseFrameAction;
		QAction *removeNodeAction;
		QAction *displayPointsAction;
		QAction *displayCurvePointsAction;
		QAction *displayCurvesAction;
		QAction *displayBorderAction;
		QAction *displayFinalAction;
		QAction *displayGhostAction;
		QAction *displayGridAction;
		QAction *displayBoundingBox;
		QAction *increaseQualityAction;
		QAction *decreaseQualityAction;
		QAction *chooseBackgroundColorAction;
		QAction *toogleOSDAction;
		QAction *playAction;
		QAction *addPosStencilAction;
		QAction *addNegStencilAction;
		QAction *highlightStencilAction;
		QAction *deleteFrameStencilsAction;
		
		QToolButton* editModeButton;
		QActionGroup *editModeActionGroup;
		QAction *editPointsAction;
		QAction *editStencilAction;
	
		// TOOLBARS
		QToolBar* toolbar;
		
		// DOCKS
		QDockWidget* informationsDock;
		QWidget* informationsDockContent;
		QVBoxLayout* informationsDockLayout;
		QTreeView* informationsTree;
		QTableView* informationsTable;
	
		// MODELS
		QStandardItemModel* _animationModel;
		PropertyItemModel* _propertyModel;
	
		// Components
		DisplayWidget* _display;
		Animation* _currentAnimation;
		QString _currentFile;
	
	private:
		void updateInformationsTree(); // Update the informations tree's model
		void updateList(); // Update the properties list's model
	
	private slots:
		void newAnimation();
		void openAnimation();
		void saveAsAnimation();
		void saveAnimation();
		
		void tooglePoints();
		void toogleCurvePoints();
		void toogleCurves();
		void toogleBorder();
		void toogleFinal();
		void toogleBoundingBox();
		void toogleGhost();
		void toogleGrid();
		void tooglePlay();
		
		void insertFrameBegin();
		void insertFrameEnd();
		void insertFrameBefore();
		void insertFrameAfter();
		
		void duplicateFrameBegin();
		void duplicateFrameEnd();
		void duplicateFrameBefore();
		void duplicateFrameAfter();
		
		void clearFrame();
		void removeFrame();
		
		void previousFrame();
		void nextFrame();
		void increaseFrameDuration();
		void decreaseFrameDuration();
		
		void deleteSelectedNode(); 
		
		void setEditPointsMode();
		void setEditStencilMode();
		
		void increaseQuality();
		void decreaseQuality();		
		
		void selectInformationsTree(const QModelIndex &index);
		
		void chooseBackgroundColor();
		void toogleOSD();
		
		void addPosStencil(); 
		void addNegStencil(); 
		void toogleDebugStencil();
		void deleteFrameStencils();
		
		void nodeSelected(Node* n);
		void nodeUpdated();
		
	public:
		MainWindow();
};

#endif